package o;

import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView.s;
import com.huawei.appgallery.foundation.ui.framework.fragment.multitabs.vertival.VerticalMultiTabsFragment;
import huawei.widget.HwTextView;
import java.util.List;
import kotlin.Metadata;
import o.dky.h;
import o.dky.i;
import o.dky.j;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@Metadata(bv = {1, 0, 3}, d1 = {"\u0000b\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010!\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0010\u000b\n\u0002\b\u0004\u0018\u0000 32\b\u0012\u0004\u0012\u00020\u00020\u0001:\u0003345B\r\u0012\u0006\u0010\u0003\u001a\u00020\u0004¢\u0006\u0002\u0010\u0005J\u0010\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\u001d\u001a\u00020\u001eH\u0002J\b\u0010\u001f\u001a\u00020\u0007H\u0016J\u0018\u0010 \u001a\u00020\u001c2\u0006\u0010!\u001a\u00020\u00022\u0006\u0010\"\u001a\u00020\u0007H\u0016J&\u0010 \u001a\u00020\u001c2\u0006\u0010!\u001a\u00020\u00022\u0006\u0010\"\u001a\u00020\u00072\f\u0010#\u001a\b\u0012\u0004\u0012\u00020%0$H\u0016J\u0018\u0010&\u001a\u00020\u00022\u0006\u0010'\u001a\u00020(2\u0006\u0010)\u001a\u00020\u0007H\u0016J\u000e\u0010*\u001a\u00020\u001c2\u0006\u0010\"\u001a\u00020\u0007J\u0015\u0010+\u001a\u00020\u001c2\b\u0010,\u001a\u0004\u0018\u00010\u0007¢\u0006\u0002\u0010-J\u001c\u0010.\u001a\u00020\u001c2\f\u0010\t\u001a\b\u0012\u0004\u0012\u00020\u000b0\n2\u0006\u0010/\u001a\u00020\u0007J\u0018\u00100\u001a\u00020\u001c2\u0006\u0010!\u001a\u00020\u00022\u0006\u00101\u001a\u000202H\u0002R\u0012\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u000e¢\u0006\u0004\n\u0002\u0010\bR\u000e\u0010\u0003\u001a\u00020\u0004X\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\t\u001a\b\u0012\u0004\u0012\u00020\u000b0\nX\u000e¢\u0006\u0002\n\u0000R\u001c\u0010\f\u001a\u0004\u0018\u00010\rX\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000e\u0010\u000f\"\u0004\b\u0010\u0010\u0011R\u001c\u0010\u0012\u001a\u0004\u0018\u00010\u0013X\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0014\u0010\u0015\"\u0004\b\u0016\u0010\u0017R\u0013\u0010\u0018\u001a\u0004\u0018\u00010\u00078F¢\u0006\u0006\u001a\u0004\b\u0019\u0010\u001a¨\u00066"}, d2 = {"Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/vertival/VerticalTabsAdapter;", "Landroidx/recyclerview/widget/RecyclerView$Adapter;", "Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/vertival/VerticalTabsAdapter$ViewHolder;", "context", "Landroid/content/Context;", "(Landroid/content/Context;)V", "_selectedPosition", "", "Ljava/lang/Integer;", "itemList", "", "Lcom/huawei/appmarket/framework/bean/TabItem;", "multiTabsSelectListener", "Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/MultiTabsSelectListener;", "getMultiTabsSelectListener", "()Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/MultiTabsSelectListener;", "setMultiTabsSelectListener", "(Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/MultiTabsSelectListener;)V", "onItemClickListener", "Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/vertival/VerticalTabsAdapter$OnItemClickListener;", "getOnItemClickListener", "()Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/vertival/VerticalTabsAdapter$OnItemClickListener;", "setOnItemClickListener", "(Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/vertival/VerticalTabsAdapter$OnItemClickListener;)V", "validSelectedPosition", "getValidSelectedPosition", "()Ljava/lang/Integer;", "adjustTextSize", "", "textView", "Lhuawei/widget/HwTextView;", "getItemCount", "onBindViewHolder", "holder", "position", "payloads", "", "", "onCreateViewHolder", "parent", "Landroid/view/ViewGroup;", "viewType", "onTabSelected", "setPreferredSelectedPosition", "selectedPosition", "(Ljava/lang/Integer;)V", "updateItemList", "preferredSelectedPosition", "updateItemSelected", "selected", "", "Companion", "OnItemClickListener", "ViewHolder", "HiAppBase_release"}, k = 1, mv = {1, 1, 15})
public final class cit extends androidx.recyclerview.widget.RecyclerView.a<b> {
    public static final c ॱ = new c();
    private List<? extends dgp> ˊ = frj.ˎ();
    @Nullable
    private d ˋ;
    @Nullable
    private cis ˎ;
    private Integer ˏ;
    private final Context ᐝ;

    @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\b\n\u0000\bf\u0018\u00002\u00020\u0001J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&¨\u0006\u0006"}, d2 = {"Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/vertival/VerticalTabsAdapter$OnItemClickListener;", "", "onItemClick", "", "position", "", "HiAppBase_release"}, k = 1, mv = {1, 1, 15})
    public interface d {
        void ˎ(int i);
    }

    @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0010\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u00012\u000e\u0010\u0002\u001a\n \u0004*\u0004\u0018\u00010\u00030\u0003H\n¢\u0006\u0002\b\u0005"}, d2 = {"<anonymous>", "", "it", "Landroid/view/View;", "kotlin.jvm.PlatformType", "onClick"}, k = 3, mv = {1, 1, 15})
    static final class a implements OnClickListener {
        final /* synthetic */ cit ˏ;
        final /* synthetic */ int ॱ;

        a(cit o_cit, int i) {
            this.ˏ = o_cit;
            this.ॱ = i;
        }

        public final void onClick(View view) {
            this.ˏ.ॱॱ(this.ॱ);
        }
    }

    @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006¨\u0006\u0007"}, d2 = {"Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/vertival/VerticalTabsAdapter$ViewHolder;", "Landroidx/recyclerview/widget/RecyclerView$ViewHolder;", "view", "Landroid/view/View;", "(Landroid/view/View;)V", "getView", "()Landroid/view/View;", "HiAppBase_release"}, k = 1, mv = {1, 1, 15})
    public static final class b extends s {
        @NotNull
        private final View ॱˋ;

        public b(@NotNull View view) {
            fsd.ˊ((Object) view, "view");
            super(view);
            this.ॱˋ = view;
        }

        @NotNull
        public final View ˊˋ() {
            return this.ॱˋ;
        }
    }

    @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0007\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\b\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004XT¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006XT¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0004XT¢\u0006\u0002\n\u0000¨\u0006\b"}, d2 = {"Lcom/huawei/appgallery/foundation/ui/framework/fragment/multitabs/vertival/VerticalTabsAdapter$Companion;", "", "()V", "autoSizeTextStep", "", "maxTabTitleLineCount", "", "minTabTitleTextSize", "HiAppBase_release"}, k = 1, mv = {1, 1, 15})
    public static final class c {
        private c() {
        }
    }

    @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\b\n\u0000\n\u0002\u0010\b\n\u0000\u0010\u0000\u001a\u00020\u0001H\n¢\u0006\u0002\b\u0002"}, d2 = {"measureTextViewHeight", "", "invoke"}, k = 3, mv = {1, 1, 15})
    static final class e extends fsc implements fry<Integer> {
        final /* synthetic */ HwTextView ˊ;
        final /* synthetic */ int ˏ;
        final /* synthetic */ int ॱ;

        e(HwTextView hwTextView, int i, int i2) {
            this.ˊ = hwTextView;
            this.ˏ = i;
            this.ॱ = i2;
            super(0);
        }

        public /* synthetic */ Object ˋ() {
            return Integer.valueOf(ˏ());
        }

        public final int ˏ() {
            this.ˊ.measure(this.ˏ, this.ॱ);
            return this.ˊ.getMeasuredHeight();
        }
    }

    public /* synthetic */ void ˋ(s sVar, int i, List list) {
        ॱ((b) sVar, i, list);
    }

    public /* synthetic */ s ˎ(ViewGroup viewGroup, int i) {
        return ˏ(viewGroup, i);
    }

    public /* synthetic */ void ॱ(s sVar, int i) {
        ˎ((b) sVar, i);
    }

    public cit(@NotNull Context context) {
        fsd.ˊ((Object) context, "context");
        this.ᐝ = context;
    }

    @Nullable
    public final Integer ॱ() {
        return this.ˏ;
    }

    public final void ˏ(@Nullable Integer num) {
        int i;
        int size = this.ˊ.size();
        fsm ˊ = fsr.ˊ(0, size);
        if (num == null || !ˊ.ˏ(num.intValue())) {
            i = 0;
        } else {
            i = 1;
        }
        if (i == 0) {
            num = size > 0 ? Integer.valueOf(0) : null;
        }
        this.ˏ = num;
    }

    public final void ˏ(@NotNull List<? extends dgp> list, int i) {
        fsd.ˊ((Object) list, "itemList");
        this.ˊ = list;
        ˏ(Integer.valueOf(i));
    }

    public final void ॱ(@Nullable d dVar) {
        this.ˋ = dVar;
    }

    public final void ˏ(@Nullable cis o_cis) {
        this.ˎ = o_cis;
    }

    @NotNull
    public b ˏ(@NotNull ViewGroup viewGroup, int i) {
        fsd.ˊ((Object) viewGroup, "parent");
        View inflate = LayoutInflater.from(this.ᐝ).inflate(i.ॱˋ, viewGroup, false);
        fsd.ॱ(inflate, "view");
        azb.ॱ((HwTextView) inflate.findViewById(h.ॱˈ));
        return new b(inflate);
    }

    public void ॱ(@NotNull b bVar, int i, @NotNull List<Object> list) {
        fsd.ˊ((Object) bVar, "holder");
        fsd.ˊ((Object) list, "payloads");
        boolean isEmpty = list.isEmpty();
        if (isEmpty) {
            ˎ(bVar, i);
        } else if (!isEmpty) {
            Object ˎ = frm.ˎ(list);
            if (!(ˎ instanceof Boolean)) {
                ˎ = null;
            }
            Boolean bool = (Boolean) ˎ;
            if (bool != null) {
                ˊ(bVar, bool.booleanValue());
                HwTextView hwTextView = (HwTextView) bVar.ˊˋ().findViewById(h.ॱˈ);
                fsd.ॱ(hwTextView, "holder.view.tab_name_text_view");
                ˋ(hwTextView);
            }
        }
    }

    public void ˎ(@NotNull b bVar, int i) {
        fsd.ˊ((Object) bVar, "holder");
        dgp o_dgp = (dgp) this.ˊ.get(i);
        HwTextView hwTextView = (HwTextView) bVar.ˊˋ().findViewById(h.ॱˈ);
        fsd.ॱ(hwTextView, "holder.view.tab_name_text_view");
        hwTextView.setText(o_dgp.ˊ());
        Integer ॱ = ॱ();
        boolean z = ॱ != null && ॱ.intValue() == i;
        ˊ(bVar, z);
        HwTextView hwTextView2 = (HwTextView) bVar.ˊˋ().findViewById(h.ॱˈ);
        fsd.ॱ(hwTextView2, "holder.view.tab_name_text_view");
        ˋ(hwTextView2);
        bVar.ˊˋ().setOnClickListener(new a(this, i));
    }

    public final void ॱॱ(int i) {
        Integer ॱ = ॱ();
        cis o_cis;
        if (ॱ != null && i == ॱ.intValue()) {
            o_cis = this.ˎ;
            if (o_cis != null) {
                o_cis.ॱॱ(i);
                return;
            }
            return;
        }
        ॱ = ॱ();
        ˏ(Integer.valueOf(i));
        if (ॱ != null) {
            int intValue = ॱ.intValue();
            ˊ(intValue, Boolean.valueOf(false));
            cis o_cis2 = this.ˎ;
            if (o_cis2 != null) {
                o_cis2.ʽ(intValue);
            }
        }
        ˊ(i, Boolean.valueOf(true));
        o_cis = this.ˎ;
        if (o_cis != null) {
            o_cis.ʼ(i);
        }
        d dVar = this.ˋ;
        if (dVar != null) {
            dVar.ˎ(i);
        }
    }

    public int ˏ() {
        return this.ˊ.size();
    }

    private final void ˊ(b bVar, boolean z) {
        int i;
        evf.ˋ((HwTextView) bVar.ˊˋ().findViewById(h.ॱˈ), z ? o.dky.d.ˊ : o.dky.d.ˋ);
        if (evf.ˋ(this.ᐝ)) {
            bVar.ˊˋ().setAlpha(z ? 1.0f : 0.6f);
        }
        evf.ॱ(bVar.ˊˋ(), z ? o.dky.d.ˏ : 17170445);
        if (z) {
            i = j.ˏ;
        } else {
            i = j.ˎ;
        }
        ((HwTextView) bVar.ˊˋ().findViewById(h.ॱˈ)).setTypeface(Typeface.create(this.ᐝ.getString(i), 0), 0);
    }

    private final void ˋ(HwTextView hwTextView) {
        int dimension = (int) this.ᐝ.getResources().getDimension(o.dky.c.ˊॱ);
        float dimension2 = this.ᐝ.getResources().getDimension(o.dky.c.ᐝॱ);
        int ˎ = epv.ˎ(this.ᐝ, dimension2);
        e eVar = new e(hwTextView, MeasureSpec.makeMeasureSpec(VerticalMultiTabsFragment.ᐝ.ˋ(this.ᐝ), 1073741824), -2);
        hwTextView.setTextSize(1, (float) ˎ);
        hwTextView.setMaxLines(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED);
        while (true) {
            if ((eVar.ˏ() > dimension || hwTextView.getLineCount() > 2) && dimension2 > 11.0f) {
                dimension2 = Math.max(11.0f, dimension2 - 1.0f);
                hwTextView.setTextSize(1, dimension2);
            }
        }
        hwTextView.setMaxLines(2);
    }
}
